/*  J
**  Date 2007-05-21 23:55:13 
**  File lex.h  v 1.0
**  Author Mucker
**  See Copyright Notice in J.h
**  
*/
#ifndef lex_h
#define lex_h

#include "J.h"
#include "io.h"
#include "object.h"
#include "chuck.h"



typedef struct lex_buff{
	char buffer[512];
	int size;
	int len;
}lex_buff;

struct lex_state{
	tag_table *ttag;
	char current;
	int line;
	JIO *jio;
	lex_buff *buff;
	token t;
	token ahead;
	
	struct parser_state *ps;

};


#define ENUM_BITFIELD(TYPE)  enum TYPE
enum rid{
	K_AND = 257,
	K_BREAK,
	K_CLASS,
	K_ELSE,  //260
	K_FALSE,
	K_IF,
	K_NEW,
	K_NIL,
	K_OR,   //265
	K_RETURN,
	K_TRUE,
	K_WHILE,
	K_EQ,
	K_GE,  //270
	K_LE,
	K_SPACE,
	K_STRING,
	K_NUMBER,
	K_DOT,  //275
	K_CONCAT,
	K_NAME,
	K_METHOD,
	K_EOF

};

#define Mreset_buff(buff) (buff->len = 0)
#define Mget_buff(buff) (buff->buffer)
#define Mlen_buff(buff) (buff->len)

J_API(void) lex_init(lex_state *ls, JIO *jio);
J_API(int) lex(lex_state *ls, token_info *info);
J_API(void) lex_out(lex_state *ls);
J_API(void) lex_ahead(lex_state *ls);
#endif
